Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class com.pacist.diamonds.Book

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--com.pacist.diamonds.Book

public class Book
extends java.awt.Panel
implements java.awt.LayoutManager2, java.awt.event.ActionListener, Direction
A component implementing a Tabbed Panel.

See Also:
Serialized Form

Field Summary
int bottomMargin
          Margin between components in pages.
java.awt.Component currentPage
          Currently active page.
DrawnButton currentTab
          Currently active tab.
DrawnButton firstBottom
          Reference to first tab.
DrawnButton firstLeft
          Reference to first tab.
DrawnButton firstRight
          Reference to first tab.
DrawnButton firstTop
          Reference to first tab.
int height
          Height of book.
int hGap
          Horizontal space left between components.
int leftMargin
          Margin between components in pages.
int pageHeight
          Height of page.
java.util.Hashtable pageMap
          Where all pages are kept.
int pageWidth
          Width of page.
int rightMargin
          Margin between components in pages.
int topMargin
          Margin between components in pages.
int vGap
          Vertical space left between components.
int width
          Width of book.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
Book()
          Creates and initializes a new Book component.
Book(int hGap, int vGap)
          Creates and initializes a new Book component, with specified horizontal and vertical gaps.
 
Method Summary
void actionPerformed(java.awt.event.ActionEvent event)
          Method that is called when a Tab is clicked on.
void addBookListener(BookListener l)
          Adds the specified Book listener to receive Book events from this Book.
void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Adds the specified component to the layout.
void addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)
          Adds the specified component to the layout.
java.awt.Component addPage(java.awt.Component page)
          This method adds a Page to the Book.
java.awt.Component addTab(DrawnButton button, java.awt.Component page)
          This method adds a Tab and Page to the Book.
java.awt.Component addTab(DrawnButton button, java.awt.Component page, int pos)
          This method adds a Tab and Page to the Book at a certain position.
void calcSizes(java.awt.Container target, boolean preferred, boolean arrowCheck)
          Calculates the margins based on the width and height of the tab buttons.
void fireBookEvent(BookEvent event)
          Processes book events occurring on this Book by dispatching them to any registered BookListener objects.
void firePageTurnedEvent(java.awt.Component oldPage, java.awt.Component newPage)
          This method notifies all Book listeners that the Page has been changed.
java.util.Vector getBookListeners()
          Returns a Vector of all Book listeners.
DrawnButton getCurrentTab()
          Returns a reference to the Tab which is currently selected.
float getLayoutAlignmentX(java.awt.Container target)
          Returns the alignment along the x axis.
float getLayoutAlignmentY(java.awt.Container target)
          Returns the alignment along the y axis.
void invalidateLayout(java.awt.Container target)
          Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
void layoutContainer(java.awt.Container target)
          Lays out the container.
java.awt.Dimension maximumLayoutSize(java.awt.Container target)
          Returns the maximum size of this component.
java.awt.Dimension minimumLayoutSize(java.awt.Container target)
          Returns the minimum dimensions needed to layout the components contained in the specified target container.
void moveAllTabs(int pos)
          Moves all Tabs to a different position.
void paint(java.awt.Graphics g)
          This method is called to repaint the Book.
java.awt.Dimension preferredLayoutSize(java.awt.Container target)
          Returns the preferred dimensions for this layout given the components in the specified target container.
void removeBookListener(BookListener l)
          Removes the specified Book listener so that it no longer receives BookEvents from this Book.
void removeLayoutComponent(java.awt.Component comp)
          Removes the specified component from the layout.
void setCurrentTab(DrawnButton button)
          Sets the currently selected Tab to the DrawnButton specified.
void setTabPosition(DrawnButton b, int pos)
          Moves a Tab to a different position.
void showPage(DrawnButton button)
          Shows the Page referenced by a specific Tab.
int tabPosition(DrawnButton tab)
          Returns the position of a Tab.
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addNotify, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponentAt, getComponentAt, getComponent, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, paint, paramString, preferredSize, printComponents, print, processContainerEvent, processEvent, removeAll, remove, remove, removeContainerListener, removeNotify, setLayout, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paint, paramString, postEvent, preferredSize, prepareImage, prepareImage, printAll, print, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

currentTab

protected DrawnButton currentTab
Currently active tab.

currentPage

protected java.awt.Component currentPage
Currently active page.

hGap

protected int hGap
Horizontal space left between components.

vGap

protected int vGap
Vertical space left between components.

leftMargin

protected int leftMargin
Margin between components in pages.

rightMargin

protected int rightMargin
Margin between components in pages.

topMargin

protected int topMargin
Margin between components in pages.

bottomMargin

protected int bottomMargin
Margin between components in pages.

pageWidth

protected int pageWidth
Width of page.

pageHeight

protected int pageHeight
Height of page.

width

protected int width
Width of book.

height

protected int height
Height of book.

pageMap

protected java.util.Hashtable pageMap
Where all pages are kept.

firstTop

protected DrawnButton firstTop
Reference to first tab.

firstBottom

protected DrawnButton firstBottom
Reference to first tab.

firstLeft

protected DrawnButton firstLeft
Reference to first tab.

firstRight

protected DrawnButton firstRight
Reference to first tab.
Constructor Detail

Book

public Book()
Creates and initializes a new Book component.

Book

public Book(int hGap,
            int vGap)
Creates and initializes a new Book component, with specified horizontal and vertical gaps.
Parameters:
hGap - Horizontal gap.
vGap - Vertical gap.
Method Detail

addTab

public java.awt.Component addTab(DrawnButton button,
                        java.awt.Component page)
This method adds a Tab and Page to the Book.
Parameters:
button - the DrawnButton which will act as the Tab; usually this will be a FlexiButton.
page - the Component which will act as the Page; usually a Panel.
Returns:
the DrawnButton specified.

addTab

public java.awt.Component addTab(DrawnButton button,
                        java.awt.Component page,
                        int pos)
This method adds a Tab and Page to the Book at a certain position.
Parameters:
button - the DrawnButton which will act as the Tab; usually this will be a FlexiButton.
page - the Component which will act as the Page; usually a Panel.
pos - the position of the Page.
Returns:
the DrawnButton specified.

addPage

public java.awt.Component addPage(java.awt.Component page)
This method adds a Page to the Book.
Parameters:
page - the Component which will act as the Page; usually a Panel.
Returns:
the page specified.

moveAllTabs

public void moveAllTabs(int pos)
Moves all Tabs to a different position.
Parameters:
pos - the position of the Tabs.
See Also:
Direction, setTabPosition(com.pacist.diamonds.DrawnButton, int)

setTabPosition

public void setTabPosition(DrawnButton b,
                           int pos)
Moves a Tab to a different position.
Parameters:
pos - the new position of the Tab.
See Also:
Direction, moveAllTabs(int)

getCurrentTab

public DrawnButton getCurrentTab()
Returns a reference to the Tab which is currently selected.
Returns:
a reference to the Tab which is currently selected.
See Also:
setCurrentTab(com.pacist.diamonds.DrawnButton)

setCurrentTab

public void setCurrentTab(DrawnButton button)
Sets the currently selected Tab to the DrawnButton specified.
Parameters:
button - the Tab to make current.
See Also:
getCurrentTab()

showPage

public void showPage(DrawnButton button)
Shows the Page referenced by a specific Tab.
Parameters:
button - the Tab which refers to a specific page.
See Also:
getCurrentTab(), setCurrentTab(DrawnButton)

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Method that is called when a Tab is clicked on.
Specified by:
actionPerformed(java.awt.event.ActionEvent) in interface java.awt.event.ActionListener
Parameters:
event - the event details.

paint

public void paint(java.awt.Graphics g)
This method is called to repaint the Book.
Parameters:
g - the graphics context to use for painting.
Overrides:
paint in class java.awt.Container

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
Adds the specified component to the layout.
Note : method not used. Completes LayoutManager interface.
Parameters:
name - the name of the component
comp - the the component to be added

addLayoutComponent

public void addLayoutComponent(java.awt.Component comp,
                               java.lang.Object constraints)
Adds the specified component to the layout.
Specified by:
addLayoutComponent(java.awt.Component, java.lang.Object) in interface java.awt.LayoutManager2
Parameters:
comp - the Tab to add.
contraints - the Page to add.

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
Removes the specified component from the layout.
Parameters:
comp - the component to remove.

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container target)
Returns the preferred dimensions for this layout given the components in the specified target container.
Parameters:
target - the component which needs to be laid out.
See Also:
java.awt.Container, minimumLayoutSize

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container target)
Returns the minimum dimensions needed to layout the components contained in the specified target container.
Parameters:
target - the component which needs to be laid out.
See Also:
preferredLayoutSize

maximumLayoutSize

public java.awt.Dimension maximumLayoutSize(java.awt.Container target)
Returns the maximum size of this component.
Specified by:
maximumLayoutSize(java.awt.Container) in interface java.awt.LayoutManager2
See Also:
getMinimumSize, getPreferredSize, java.awt.LayoutManager

getLayoutAlignmentX

public float getLayoutAlignmentX(java.awt.Container target)
Returns the alignment along the x axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.
Specified by:
getLayoutAlignmentX(java.awt.Container) in interface java.awt.LayoutManager2

getLayoutAlignmentY

public float getLayoutAlignmentY(java.awt.Container target)
Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.
Specified by:
getLayoutAlignmentY(java.awt.Container) in interface java.awt.LayoutManager2

invalidateLayout

public void invalidateLayout(java.awt.Container target)
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
Specified by:
invalidateLayout(java.awt.Container) in interface java.awt.LayoutManager2

tabPosition

protected int tabPosition(DrawnButton tab)
Returns the position of a Tab.
Parameters:
tab - the Tab we are interested in.
Returns:
the position of the Tab.
See Also:
Direction

calcSizes

protected void calcSizes(java.awt.Container target,
                         boolean preferred,
                         boolean arrowCheck)
Calculates the margins based on the width and height of the tab buttons.
Parameters:
target - the specified component being laid out.
preferred - TRUE - use preferredSize(). FALSE - use minimumSize().

layoutContainer

public void layoutContainer(java.awt.Container target)
Lays out the container.
Parameters:
target - the specified component being laid out.
See Also:
java.awt.Container

firePageTurnedEvent

protected void firePageTurnedEvent(java.awt.Component oldPage,
                                   java.awt.Component newPage)
This method notifies all Book listeners that the Page has been changed.
Parameters:
oldPage - the previously selected Page.
newPage - the new currently selected Page.

getBookListeners

protected java.util.Vector getBookListeners()
Returns a Vector of all Book listeners.
Returns:
a list of all Book listeners.

addBookListener

public void addBookListener(BookListener l)
Adds the specified Book listener to receive Book events from this Book. Book events occur when a user changes the currently selected page.

removeBookListener

public void removeBookListener(BookListener l)
Removes the specified Book listener so that it no longer receives BookEvents from this Book.

fireBookEvent

protected void fireBookEvent(BookEvent event)
Processes book events occurring on this Book by dispatching them to any registered BookListener objects.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD